package com.sun.boostrap.controller;

import com.sun.annotation.Log;
import com.sun.exception.MyException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ExceptionController {

    @Log
    @GetMapping("/xx")
    public String test(){
        int a = 10;
        return "结果:" + a / 0 ;
    }

    @RequestMapping("/ss")
    public String test2() {
        int a = 10 - 8;
        if (a == 2) {
            throw new MyException("1001", "empty", "/API/getUserName", "在获取用户名字的时候为空");
        }
        return a + "";
    }
}
